#include "StartCompetitions.h"
#include "FiniteStateMachine.h"
#include "UpdateRanking.h"
#include "ExitGame.h"


StartCompetitions::StartCompetitions(void)
{
}


StartCompetitions::~StartCompetitions(void)
{
}

void StartCompetitions::Execute( void* aFsm )
{
	FiniteStateMachine<Game>* fsmGame= reinterpret_cast<FiniteStateMachine<Game>*>(aFsm);
	Game *game= fsmGame->mActor;
	//inizializzo la macchina a stati per la gestione dell'intero torneo
	Tournament tournament(game->challengeTree, game->boxerArray);
	FiniteStateMachine<Tournament> fsmT(&tournament);
	fsmT.Start(new UpdateRanking);
	while(!tournament.mChallengeTree->GetRoot()->mItem){
		fsmT.Execute();
	}
	std::cout<< std::endl<< "IL CAMPIONE DEL MONDO DI BOXE, CATEGORIA PESI VIRTUALI, E': " << tournament.mChallengeTree->GetRoot()->mItem->GetName() << std::endl;
	fsmGame->ChangeState(new ExitGame());


}
